<template>
  <div class="Detail-container">
    <table rules="cols" class="table">
      <tr>
        <td>{{ SdkName }}</td>
      </tr>
      <tr align="center">
        <td>创建时间：{{ CreateTime }}</td>
        <td>需求方：{{ SdkDescribe }}</td>
        <td>当前状态
          <el-tag :type="Status | statusFilter">
            <i :class="Status | statusIconFilter" />
            {{ Status | statusTextFilter }}
          </el-tag>
        </td>
      </tr>
      <tr align="center">
        <td>需求类型：{{ ProjectId | categoryTypeFilter }}</td>
        <td>接口人：{{ Operator }}</td>
      </tr>
    </table>

    <el-tabs v-model="activeId" class="tabs" @tab-click="handleClick">
      <el-tab-pane label="评测标准" name="0">
        <el-row>
          <el-col>
            <el-button type="primary"><a download="评测标准.doc" :href="href">下载文档</a></el-button>
            <el-button type="primary"><a upload="评测标准.doc" :href="href">上传文档</a></el-button>
          </el-col>
        </el-row>

        <div v-loading="wordLoading" class="vhtmlbox" v-html="vHtml" />
      </el-tab-pane>
      <el-tab-pane label="数据集" name="1">
        <el-table
          :key="2"
          v-loading="listLoading"
          :data="dataList"
          border
          fit
          highlight-current-row
          style="width: 100%;"
        >
          <el-table-column label="名称" prop="Name" align="center" />
          <el-table-column label="类别" prop="Class" align="center" />
          <el-table-column label="来源" prop="From" align="center" />
          <el-table-column label="数量" width="100" prop="Count" align="center" />
          <el-table-column label="状态" width="150" prop="Status" align="center">
            <template slot-scope="{row}">
              <el-tag :type="row.Status | statusFilter">
                <i :class="row.Status | statusIconFilter" />
                {{ row.Status | statusTextFilter }}
              </el-tag>
            </template>
          </el-table-column>
          <el-table-column label="创建时间" prop="CreateTime" align="center" width="200" />
          <el-table-column label="操作" align="center" width="200" class-name="small-padding fixed-width">
            <template slot-scope="{row}">
              <el-button-group>
                <el-button type="primary" size="mini" title="查看" @click="handleVideoList(row)">查看</el-button>
                <el-button type="danger" size="mini" title="删除">删除</el-button>
                <el-button type="success" size="mini" title="上传" @click="handleUpload(row)">上传</el-button>
              </el-button-group>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="算法版本" name="2">
        <el-row>
          <el-col>
            <el-button type="primary" @click="handleNewtask">新增算法版本</el-button>
          </el-col>
        </el-row>
        <el-table
          v-loading="listLoading"
          :data="versionList"
          style="width: 100%"
        >
          <el-table-column prop="Version" label="版本名称" />
          <el-table-column prop="Describe" label="需求类型" />
          <el-table-column label="需求方" prop="InputType" align="center">
            <template slot-scope="{row}">
              <span>{{ row.InputType | formatTypeFilter }}</span>
            </template>
          </el-table-column>
          <el-table-column label="接口人" prop="OutputType" align="center">
            <template slot-scope="{row}">
              <span>{{ row.OutputType | formatTypeFilter }}</span>
            </template>
          </el-table-column>
          <!-- 新增操作人字段 -->
          <el-table-column label="操作人" prop="OutputType" align="center">
            <template slot-scope="{row}">
              <span>{{ row.OutputType | formatTypeFilter }}</span>
            </template>
          </el-table-column>
          <!-- 去掉状态字段 -->
         <!--  <el-table-column
            label="状态"
            width="150"
            align="center"
          >
            <template slot-scope="{row}">
              <el-tag :type="row.Status | statusFilter">
                <i :class="row.Status | statusIconFilter" />
                {{ row.Status | statusTextFilter }}
              </el-tag>
            </template>
          </el-table-column> -->
          <el-table-column label="操作">
            <template slot-scope="{}">
              <el-button-group>
                <el-button type="primary" size="mini" title="查看">查看</el-button>
                <el-button type="success" size="mini" title="详情">详情</el-button>
              </el-button-group>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="评测任务" name="3">
        <el-row>
          <el-col>
            <el-button type="primary" @click="taskAnalysis">分析报告</el-button>
          </el-col>
        </el-row>
        <el-table
          v-loading="listLoading"
          :data="taskList"
          style="width: 100%"
          @select="taskSelect"
          @select-all="taskSelectAll"
        >
          <el-table-column
            type="selection"
            width="55"
          />
          <el-table-column width="80" prop="Id" label="任务ID" />
          <el-table-column label="数据集" prop="DatasetName" align="center" />
          <el-table-column label="算法版本" prop="VersionName" align="center" />
          <el-table-column label="任务状态">
            <template slot-scope="{row}">
              <el-tag :type="row.Status | statusTaskFilter">
                <i :class="row.Status | statusIconFilter" />
                {{ row.Status | statusTaskTextFilter }}
              </el-tag>
            </template>
          </el-table-column>
          <el-table-column prop="CreateTime" label="提交时间" />
          <el-table-column prop="Do" sortable label="操作" align="center" width="320">
            <template slot-scope="{row}">
              <el-button-group style="background-color:rgb（74,89,197）border:rgb（74,89,197）">
                <el-button type="primary" size="medium" title="分析" @click="handleAnalyses(row)">分析</el-button>
                <el-button type="primary" size="medium" title="报告" @click="handleReport(row)">报告</el-button>
                <el-button type="primary" size="medium" title="修改" @click="handleModify(row)">修改</el-button>
                <el-button type="danger" size="medium" title="删除" @click="handleDelete(row)">删除</el-button>
               <!--  <el-button type="danger" size="mini" title="删除">删除</el-button>
                <el-button type="success" size="mini" title="上传" @click="handleUpload(row)">上传</el-button> -->
              </el-button-group>
            </template>
          </el-table-column>
        </el-table>
        <pagination v-show="taskTotal>0" :total="taskTotal" :page.sync="taskQuery.Page" :limit.sync="taskQuery.Size" style="text-align:right" @pagination="handleClick" />
      </el-tab-pane>
      <el-tab-pane label="排行榜" name="4">
        <el-row>
          <el-col :span="6">
            <el-select v-model="getTaskResTemp.DataSetId" placeholder="请选择" @change="getTaskResultList">
              <el-option
                v-for="item in dataSetOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-col>
          <el-col :span="6">
            <el-select v-model="getTaskResTemp.taskResultList" multiple placeholder="请选择" @change="showTaskResList">
              <el-option
                v-for="item in taskResultOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-col>
        </el-row>
        <ve-line v-if="isHaveRes" :data="chartData" />
        <el-table
          v-loading="listLoading"
          :data="showTaskResultList"
          style="width: 100%;"
        >
          <!--          @select="taskSelect"-->
          <!--          @select-all="taskSelectAll"-->
          <el-table-column prop="VersionId" width="80" sortable label="ID" align="center" />
          <el-table-column prop="VersionNum" width="120" sortable label="版本号" align="center" />
          <el-table-column prop="DataSetName" label="数据集" align="center" />
          <el-table-column prop="Accuracy" sortable label="Accuracy" align="center" />
          <el-table-column prop="Recall" sortable label="recall" align="center" />
          <el-table-column prop="ImageRecall" sortable label="ImageRecall" align="center" />
          <el-table-column prop="AvgLabelNum" sortable label="AvgLabelNum" align="center" />
          <el-table-column prop="CreateTime" sortable label="提交时间" />
        </el-table>
      </el-tab-pane>
    </el-tabs>

    <el-dialog title="新建算法" :visible.sync="dialogNewtask" width="60%">
      <el-form
        ref="dataForm"
        :model="temp"
        label-position="left"
        label-width="100px"
        style="width: 400px; margin: 0 auto"
      >
        <el-form-item label="版本">
          <el-input v-model="temp.Version" />
        </el-form-item>
        <el-form-item label="版本描述">
          <el-input v-model="temp.Describe" />
        </el-form-item>
        <!--   <div class="temp-left" style="margin-left:-200px;">
          <el-form-item label="任务名称">
            <el-input v-model="temp.taskName"> </el-input>
          </el-form-item>
           <el-form-item label="需求方">
            <el-input v-model="temp.demander"> </el-input>
          </el-form-item>
           <el-form-item label="接口人">
            <el-input v-model="temp.interfacer"> </el-input>
          </el-form-item>
        </div> -->
        <!--   <span><i>｜</i></span>
        <el-form-item label="输入类型">
          <el-radio>文本<el-radio>
          <el-radio>视频<el-radio>
          <el-radio>图片<el-radio>
        </el-form-item>
        <el-form-item label="输出类型">
          <el-radio>文本<el-radio>
          <el-radio>视频<el-radio>
          <el-radio>图片<el-radio>
        </el-form-item>
        <el-form-item label="报告模式">
          <el-radio>文本<el-radio>
          <el-radio>视频<el-radio>
          <el-radio>图片<el-radio>
        </el-form-item> -->
        <el-form-item label="请求类型">
          <el-radio-group v-model="temp.RequestType">
            <el-radio :label="0">镜像</el-radio>
            <el-radio :label="1">服务</el-radio>
            <el-radio :label="2">SDK</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item v-if="temp.RequestType===0" label="镜像地址">
          <el-input v-model="temp.MirrorUrl" />
        </el-form-item>
        <el-form-item label="请求URL">
          <el-input v-model="temp.RequestUrl" />
        </el-form-item>
        <el-form-item label="请求报文">
          <el-input v-model="temp.RequestBody" />
        </el-form-item>
        <el-form-item label="结果字段">
          <el-input v-model="temp.ResultKey" />
        </el-form-item>
        <el-form-item label="请求方式">
          <el-radio-group v-model="temp.Method">
            <el-radio :label="0">同步</el-radio>
            <el-radio :label="1">异步</el-radio>
          </el-radio-group>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogNewtask = false">取消</el-button>
        <el-button type="primary" @click="createData()">新建</el-button>
      </div>
    </el-dialog>
    <el-dialog title="数据详情" :visible.sync="dialogVisible" width="80%">
      <el-table
        :key="tableKey"
        v-loading="listInfoLoading"
        :data="listInfo"
        border
        fit
        highlight-current-row
        style="width: 100%;"
      >
        <el-table-column label="序号" prop="Id" align="center" />
        <el-table-column label="文件名" prop="Name" min-width="150px" align="center" />
        <el-table-column label="文件大小" prop="Size" align="center" />
        <el-table-column label="格式" prop="Format" align="center" />
      </el-table>
      <pagination v-show="totalInfo>0" :total="totalInfo" :page.sync="listInfoQuery.Page" :limit.sync="listInfoQuery.Size" style="text-align:right" @pagination="handleVideoList" />
    </el-dialog>
    <el-dialog title="上传数据" :visible.sync="dialogUpload" width="60%">
      <uploader
        :options="uploadOptions"
        class="uploader-example"
      >
        <uploader-unsupport />
        <uploader-drop>
          <P>Drop files here to upload or</P>
          <uploader-btn v-if="DataSetType===0" ref="selectVideo" :attrs="attrsVideo">select videos</uploader-btn>
          <uploader-btn v-else ref="selectImage" :attrs="attrsImage">select images</uploader-btn>
          <uploader-btn :directory="true">select folder</uploader-btn>
        </uploader-drop>
        <uploader-list />
      </uploader>
    </el-dialog>
  </div>
</template>

<script>
import {
  fetchGetDataSetList,
  fetchVersionList,
  fetchVersionInfo,
  CreateVersion,
  fetchSdkInfo,
  fetchGetDataSetInfo,
  fetchTaskResultList
} from '@/api/video'
import { mapGetters } from 'vuex'
import { fetchTaskList } from '@/api/task'
import mammoth from 'mammoth'
import Pagination from '@/components/Pagination' // secondary package based on el-pagination

export default {
  name: 'Detail',
  filters: {
    statusFilter(status) {
      const statusMap = {
        '0': 'success',
        '-1': 'danger'
      }
      return statusMap[status]
    },
    statusTaskFilter(status) {
      const statusMap = {
        '0': '',
        '1': '',
        '2': '',
        '3': 'info',
        '4': 'success',
        '-1': 'danger'
      }
      return statusMap[status]
    },
    statusIconFilter(status) {
      const statusMap = {
        '0': 'el-icon-check',
        '-1': 'el-icon-close'
      }
      return statusMap[status]
    },
    statusTextFilter(status) {
      const statusMap = {
        '0': '已评测',
        '-1': '未评测'
      }
      return statusMap[status]
    },
    statusTaskTextFilter(status) {
      const statusMap = {
        '0': '创建完成',
        '1': '评测执行',
        '2': '预测完成',
        '3': '评测标注',
        '4': '评测完成',
        '-1': '任务出错'
      }
      return statusMap[status]
    },
    categoryTypeFilter(status) {
      const statusMap = {
        '-1': '无',
        '1': '低俗审核',
        '2': '内容理解',
        '3': '智能识别',
        '5': '优质挖掘'
      }
      return statusMap[status]
    },
    formatTypeFilter(status) {
      const statusMap = {
        '0': '视频类型',
        '1': '图片类型',
        '2': '文本类型'
      }
      return statusMap[status]
    }
  },
  components: { Pagination },
  data() {
    return {
      isHaveRes: false,
      vHtml: '',
      dialogNewtask: false,
      wordLoading: false,
      input: '',
      dataList: null,
      versionList: null,
      taskList: null,
      total: 0,
      listLoading: false,
      activeId: '0',
      SdkName: '',
      CreateTime: '',
      SdkDescribe: '',
      Operator: '',
      Status: '',
      SdkId: 0,
      Do:'',
      buf: null,
      href: '',
      taskTotal: 0,
      taskQuery: {
        Page: 1,
        Size: 10
      },
      temp: {
        Version: '', // 版本
        Describe: '', // 版本描述
        RequestUrl: '', // 请求url
        RequestBody: '', // 请求报文
        ResultKey: '', // 结果字段
        RequestType: 0, // 请求类型（0：镜像 1：服务 2：SDK）
        MirrorUrl: '', // 镜像地址（只有请求是镜像时候需要）
        Method: 0, // 请求方式（0：同步，1：异步）
        ResponseBody: '', // 返回报文 默认
        ReportType: 0, // 报告类型 0:通用标签 1:分类识别 默认
        InputType: 0, // 版本输入类型（0：图片 1：视频 2：文本） 默认
        OutputType: 0, // 版本输出类型（0：图片 1：视频 2：文本） 默认
        taskName: '', // 选择服务时-任务名称
        demander: '', // 选择服务时-需求方
        interfacer: '' // 选择服务时-接口人
      },
      infoId: 0,
      dialogVisible: false,
      listInfoLoading: false,
      listInfo: null,
      tableKey: 0,
      totalInfo: 0,
      listInfoQuery: {
        Page: 1,
        Size: 10
      },

      dialogUpload: false,
      uploadOptions: {
        target: '/upload',
        fileParameterName: 'File',
        chunkSize: 10 * 1024 * 1024 * 1024,
        query: {
          DataSetId: -1
        },
        testChunks: false,
        parseTimeRemaining: function(timeRemaining, parsedTimeRemaining) {
          return parsedTimeRemaining
            .replace(/\syears?/, '年')
            .replace(/\sdays?/, '天')
            .replace(/\shours?/, '小时')
            .replace(/\sminutes?/, '分钟')
            .replace(/\sseconds?/, '秒')
        },
        categoryMap: {
          image: ['gif', 'jpg', 'jpeg', 'png', 'bmp', 'webp'],
          video: ['mp4', 'm3u8', 'rmvb', 'avi', 'swf', '3gp', 'mkv', 'flv'],
          audio: ['mp3', 'wav', 'wma', 'ogg', 'aac', 'flac'],
          document: ['doc', 'txt', 'docx', 'pages', 'epub', 'pdf', 'numbers', 'csv', 'xls', 'xlsx', 'keynote', 'ppt', 'pptx']
        }
      },
      attrsVideo: {
        accept: 'video/*'
      },
      attrsImage: {
        accept: 'image/*'
      },
      DataSetType: 0,
      taskMulSel: [],
      // 排行榜
      dataSetOptions: [],
      taskResultOptions: [],
      getTaskResTemp: {
        DataSetId: '',
        taskResultList: []
      },
      showTaskResultList: [],
      taskResultList: {},
      chartData: {
        columns: ['版本号', 'Accuracy', 'Recall', 'ImageRecall', 'AvgLabelNum'],
        rows: [
        ]
      }
    }
  },
  computed: {
    ...mapGetters([
      'ProjectId'
    ]),
    watchProjectId() {
      return this.$store.state.constants.ProjectId
    }
  },
  watch: {
    // watchProjectId(curVal, oldVal) {
    //   this.$router.push({ path: '/dashboard', query: { id: this.ProjectId }})
    // }
  },
  created() {
    const detail = JSON.parse(sessionStorage.getItem('SET_DETAIL'))
    //   SdkName: row.SdkName,
    //   CreateTime: row.CreateTime,
    //   SdkDescribe: row.SdkDescribe,
    //   Operator: row.Operator,
    //   Status: row.Status
    this.SdkName = detail.SdkName
    this.CreateTime = detail.CreateTime
    this.SdkDescribe = detail.SdkDescribe
    this.Operator = detail.Operator
    this.Status = detail.Status
    this.SdkId = detail.SdkId
    this.handleShowFile()
  },
  methods: {
    showTaskResList() {
      this.showTaskResultList = []
      this.chartData.rows = []
      this.getTaskResTemp.taskResultList.forEach(item => {
        var taskResult = this.taskResultList[item]
        this.showTaskResultList.push(this.taskResultList[item])
        this.chartData.rows.push({ '版本号': taskResult.VersionNum, 'Accuracy': taskResult.Accuracy, 'recall': taskResult.Recall, 'ImageRecall': taskResult.ImageRecall, 'AvgLabelNum': taskResult.AvgLabelNum })
      })
    },
    getTaskResultList() {
      // const param = {
      //   DataSetId: this.getTaskResTemp.DataSetId,
      //   SdkId: this.SdkId
      // }

      // 测试用例
      const param = {
        DataSetId: 82,
        SdkId: 8
      }
      fetchTaskResultList(param).then(res => {
        res.Data.map(item => {
          item = JSON.parse(item)
          item.Recall = item.Recall.toFixed(5)
          item.Accuracy = item.Accuracy.toFixed(5)
          this.taskResultList[item.VersionId] = item
          var resOption = {}
          resOption['value'] = item.VersionId
          resOption['label'] = item.VersionNum
          this.taskResultOptions.push(resOption)
          console.log(this.taskResultOptions)
        })
        console.log(this.taskResultList)
      })
    },
    taskAnalysis() {
      if (this.taskMulSel.length === 0) {
        return
      }
    },
    taskSelectAll(selection) {
      this.taskMulSel = []
      selection.map(item => {
        this.taskMulSel.push(item.Id)
      })
      console.log(this.taskMulSel)
      // TODO: 等接口
    },
    taskSelect(selection, row) {
      this.taskMulSel = []
      selection.map(item => {
        this.taskMulSel.push(item.Id)
      })
      console.log(this.taskMulSel)
      // TODO: 等接口
    },
    handleVideoList(row) {
      this.dialogVisible = true
      if (row.Id) {
        this.infoId = row.Id
      }
      this.listInfoLoading = true
      const params = {
        ...this.listInfoQuery,
        DataSetId: this.infoId
      }
      fetchGetDataSetInfo(params).then(response => {
        this.listInfo = response.Data.map(item => {
          var size = item.Size / 1024 / 1024
          item.Size = size.toFixed(3) + 'MB'
          return item
        })
        this.totalInfo = response.Count

        // Just to simulate the time of the request
        setTimeout(() => {
          this.listInfoLoading = false
        }, 0.5 * 1000)
      }).catch(() => {
        this.listInfoLoading = false
      })
    },
    handleNewtask() {
      this.temp = {
        Version: '', // 版本
        Describe: '', // 版本描述
        RequestUrl: '', // 请求url
        RequestBody: '', // 请求报文
        ResultKey: '', // 结果字段
        RequestType: 0, // 请求类型（0：镜像 1：服务 2：SDK）
        MirrorUrl: '', // 镜像地址（只有请求是镜像时候需要）
        Method: 0, // 请求方式（0：同步，1：异步）
        ResponseBody: '', // 返回报文 默认
        ReportType: 0, // 报告类型 0:通用标签 1:分类识别 默认
        InputType: 0, // 版本输入类型（0：图片 1：视频 2：文本） 默认
        OutPutType: 0 // 版本输出类型（0：图片 1：视频 2：文本） 默认
        /* taskName:'',// 选择服务时-任务名称
        demander:'',// 选择服务时-需求方
        interfacer:''//选择服务时-接口人*/
      }
      const sdkid = {
        SdkId: this.SdkId
      }
      fetchSdkInfo(sdkid).then(response => {
        this.temp.OutPutType = response.Data[0].OutPutType
        this.temp.InputType = response.Data[0].InputType
        this.temp.ReportType = response.Data[0].ReportType
        this.temp.MirrorUrl = response.Data[0].mirror
        this.temp.RequestUrl = response.Data[0].url
        this.temp.RequestBody = response.Data[0].request
        this.temp.ResultKey = response.Data[0].Need
        this.temp.RequestType = response.Data[0].RequestType
      })
      this.dialogNewtask = true
    },
    handleUpload(row) {
      this.dialogUpload = true
      this.DataSetType = row.Type
      this.uploadOptions.query.DataSetId = row.Id
      this.$nextTick(() => {
        if (this.DataSetType === 0) {
          this.$refs.selectVideo.$el.children[0].accept = 'video/*'
        } else {
          this.$refs.selectImage.$el.children[0].accept = 'image/*'
        }
      })
    },
    createData() {
      const params = {
        ...this.temp,
        ProjectId: Number(this.ProjectId),
        SdkId: this.SdkId
      }
      CreateVersion(params).then(response => {
        this.dialogNewtask = false
        this.getList()
      })
    },
    handleShowFile() {
      this.wordLoading = true
      const params = {
        SdkId: this.SdkId
      }
      fetchVersionInfo(params).then(res => {
        var bs64String = 'data:application/msword;base64,' + res.Data[0].File
        var arr = bs64String.split(',')
        var _arr = arr[1].substring(0, arr[1].length - 2)
        var mime = arr[0].match(/:(.*?);/)[1]
        var bstr = atob(_arr)
        var n = bstr.length
        var u8arr = new Uint8Array(n)
        while (n--) {
          u8arr[n] = bstr.charCodeAt(n)
        }
        var blob = new Blob([u8arr], { type: mime })
        this.href = URL.createObjectURL(blob)

        const allBuffer = atob(res.Data[0].File).split('').map(function(c) { return c.charCodeAt(0) })
        mammoth.convertToHtml({ arrayBuffer: allBuffer }).then((result) => {
          this.vHtml = result.value
          this.wordLoading = false
          this.$nextTick().then((res) => {
            document.getElementsByClassName('vhtmlbox')[0].children[0].style.borderRight = '1px solid #F00'
            document.getElementsByClassName('vhtmlbox')[0].children[0].style.borderBottom = '1px solid #F00'
            var trs = document.getElementsByClassName('vhtmlbox')[0].children[0].children[0].children
            for (var i = 0; i < trs.length; i++) {
              var tds = trs[i].children
              for (var j = 0; j < tds.length; j++) {
                var td = tds[j]
                td.style.borderLeft = '1px solid #F00'
                td.style.borderTop = '1px solid #F00'
              }
            }
          })
        }).done()
      }).catch(
        () => {
          this.wordLoading = false
        }
      )
    },
     /*操作部分的四个按钮事件处理*/
     handleAnalyses(){

     },
     handleReport(){

     },
     handleModify(){

     },
     handleDelete(){

     },
    handleClick() {
      this.versionList = null
      this.taskList = null
      var params
      switch (this.activeId) {
        case '0':
        case '1':
          this.listLoading = true
          params = {
            Page: 1,
            Size: 10,
            SdkId: this.SdkId
          }
          fetchGetDataSetList(params).then(response => {
            this.dataList = response.Data

            setTimeout(() => {
              this.listLoading = false
            }, 0.5 * 1000)
          }).catch(() => {
            this.listLoading = false
          })
          break
        case '2':
          this.listLoading = true
          params = {
            SdkId: this.SdkId
          }
          fetchVersionList(params).then(response => {
            this.versionList = response.Data

            setTimeout(() => {
              this.listLoading = false
            }, 0.5 * 1000)
          }).catch(() => {
            this.listLoading = false
          })
          break
        case '3':
          this.listLoading = true
          params = {
            ...this.taskQuery,
            ProjectId: this.ProjectId,
            SdkId: this.SdkId
          }
          fetchTaskList(params).then(response => {
            this.taskList = response.Data
            this.taskTotal = response.Count

            // Just to simulate the time of the request
            setTimeout(() => {
              this.listLoading = false
            }, 0.5 * 1000)
          }).catch(() => {
            this.listLoading = false
          })
          break
        case '4':
          params = {
            Page: 1,
            Size: 10,
            SdkId: -1
          }
          fetchGetDataSetList(params).then(response => {
            response.Data.map(item => {
              var dataoption = {}
              dataoption['value'] = item.Id
              dataoption['label'] = item.Name
              this.dataSetOptions.push(dataoption)
            })
            setTimeout(() => {
              this.listLoading = false
            }, 0.5 * 1000)
          }).catch(() => {
            this.listLoading = false
          })
          this.$nextTick().then(res => {
            this.isHaveRes = true
          })
          break
      }
      return
    }
  }
}
</script>

<style lang="scss" scoped>
.dashboard {
  &-container {
    margin: 30px;
  }
  &-text {
    font-size: 30px;
    line-height: 46px;
  }
}
.table {
  width: 80%;
  margin: 5%;
}
.tabs {
  margin: 0 5%;
}
.el-row {
  margin-bottom: 20px;
  &:last-child {
    margin-bottom: 0;
  }
}
.el-col {
  border-radius: 4px;
}
.bg-purple-dark {
  background: #99a9bf;
}
.bg-purple {
  background: #d3dce6;
}
.bg-purple-light {
  background: #e5e9f2;
}
.grid-content {
  border-radius: 4px;
  min-height: 36px;
}
.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}
.chart-wrapper {
  background: #fff;
  padding: 16px 16px 0;
  margin-bottom: 32px;
}
/*.temp-left .el-form-item .el-input{
  width:300px;
}*/

</style>
